<style>

    .media{

        margin-bottom: 20px;
        border: 1px solid #efefef;
        clear: left;

    }
    .media .speci-lists{

        width: 100%;
        height: auto;
        border: 1px solid #ccc;
        position: relative;
        bottom: -10px;
        background: #fff;
        z-index: 9;
        padding: 5px 5px 0 5px;
        margin-bottom: 10px;

    }
    .media .speci-lists ul{

        width: auto;
        height: 100%;
        margin: 0;
        padding: 0;
        overflow: auto;
        white-space: nowrap;

    }
    .media .speci-lists ul li{

        width: 130px;
        height: auto;
        border-right: 1px dashed #ccc;
        display: inline-block;
        padding: 0 5px;

    }
    .media .speci-lists ul li:first-child{

        border-left: 1px dashed #ccc;

    }
    .media .speci-lists ul li .thumb{

        width: 100%;
        height: 80px;
        margin-bottom: 10px;

    }
    .media .speci-lists ul li .thumb img{

        width: 100%;
        height: 100%;

    }
    .media .speci-lists ul li .goods-spec{

        font-size: 12px;
        font-weight: bold;
        color: #888;

    }
    .media .speci-lists ul li .goods-spec strong{

        color: #448944;

    }
    .media .bar{

        width: 100%;
        height: 30px;
        background: #efefef;
        padding: 5px;
        margin-bottom: 5px;

    }
    .media .bar .btn{

        margin-left: 5px;

    }
    .status_bar{

        width: 100%;
        margin-bottom: 10px;
        background: #efefef;
        padding: 5px;
        margin-bottom: 5px;

    }
    .media-body{
        height: 64px;
    }
    .media-body{
        vertical-align: middle;
    }
    .speci-lists .triangle{
        display: block;
        border-color: transparent transparent #ccc;
        border-style: dashed dashed solid;
        border-width: 0 9px 9px;
        width: 0;
        height: 0;
        line-height: 0;
        position: absolute;
        left: 18px;
        top: -9px;
    }
    .triangle i{
        border-color: transparent transparent #fff;
        border-style: dashed dashed solid;
        border-width: 0 7px 7px;
        width: 0;
        height: 0;
        line-height: 0;
        position: absolute;
        left: -7px;
        top: 2px;
        z-index: 2;
    }
    .goods-spec.title{

        font-size: 12px !important;
        line-height: 16px;
        font-weight: 300 !important;
        white-space: normal;
        margin-bottom: 5px;


    }
</style>
<table class="table table-hover" id="after-sales-list">
    <tr>
        <th style="border:none;">ID</th>
        <th style="border:none;">联系人</th>
        <th style="border:none;">订单信息</th>
        <th style="border:none;">状态</th>
        <th style="border:none;">描述</th>
        <th style="border:none;">类型</th>
        <th style="border:none;">申请时间</th>
        <th style="border:none;">开始处理</th>
        <th style="border:none;">处理完成</th>
        <th style="border:none;">联系电话</th>
        <th style="border:none;">处理结果</th>
        <th style="border:none;">备注</th>
        <th style="border:none;">操作</th>
    </tr>
    <?php if($data):?>
        <?php foreach($data as $v):?>
            <tr>
                <td><?php echo $v['id']?></td>
                <td>

                    <?php echo $v['contacts']?>

                </td>
                <td>
                    <a href="javascript:;" data-order_id="<?php echo $v['order_id']?>" class="btn btn-default btn-xs order-info">点击查看</a>
                </td>
                <td>

                    <?php if($v['progress'] == 1):?>
                        <span class="red">待处理</span>
                    <?php elseif($v['progress'] == 2):?>
                        <span class="orange">处理中</span>
                    <?php elseif($v['progress'] == 3):?>
                        <span class="green">处理完成</span>
                    <?php endif;?>


                </td>
                <td>
                    <span  data-toggle="tooltip" data-placement="top" title="<?php echo $v['description']?>">
                    <?php echo str_cut($v['description'],20,'...')?>
                    </span>
                </td>
                <td>
                    <?php echo $v['problem_type_name']?>
                </td>
                <td>
                    <span data-toggle="tooltip" data-placement="top" title="<?php echo date('Y-m-d H:i:s',$v['create_time']);?>">
                        <?php echo date('m-d',$v['create_time']);?>
                    </span>
                </td>
                <td>
                    <span data-toggle="tooltip" data-placement="top" title="<?php echo $v['processing_time'] ? date('Y-m-d H:i:s',$v['processing_time']) : '';?>">
                        <?php echo $v['processing_time'] ? date('m-d',$v['processing_time']) : '';?>
                    </span>
                </td>
                <td>
                    <span data-toggle="tooltip" data-placement="top" title="<?php echo $v['complete_time'] ? date('Y-m-d H:i:s',$v['complete_time']) : '';?>">
                        <?php echo $v['complete_time'] ? date('m-d',$v['complete_time']) : '';?>
                    </span>
                </td>
                <td>
                    <?php echo $v['mobile']?>
                </td>
                <td>

                    <?php if(!$v['result']):?>
                        <?php if($v['progress'] == 1):?>
                            <span class="red">待处理</span>
                        <?php elseif($v['progress'] == 2):?>
                            <span class="orange">处理中</span>
                        <?php elseif($v['progress'] == 3):?>
                            <span class="green">处理完成</span>
                        <?php endif;?>
                    <?php elseif($v['result'] == 1):?>
                        <span class="green">申请通过</span>
                    <?php elseif($v['result'] == 2):?>
                        <span class="red">申请被拒绝</span>
                    <?php endif;?>

                </td>
                <td>
                    <span data-toggle="tooltip" data-placement="top" title="<?php echo $v['reason']?>">
                        <?php echo str_cut($v['reason'],20,'...')?>
                    </span>
                </td>
                <td data-id="<?php echo $v['id']?>" data-number="<?php echo $v['order_info']['number']?>" data-mobile="<?php echo $v['mobile']?>">
                    <?php

                        foreach($v['images'] as $key=>$val){

                            $pic[$key]['alt'] = '';
                            $pic[$key]['src'] = '/'.ltrim($val,'/');
                            $pic[$key]['thumb'] = '/'.ltrim(cutUrl($val,200,0),'/');

                        }
                    ?>

                    <a href="javascript:;" data-pic=<?php echo json_encode($pic);?> class="btn btn-default btn-xs images radius-none">查看图片</a>

                    <?php if($v['progress'] == 1):?>
                        <a href="javascript:;" class="btn btn-success btn-xs start radius-none">开始处理</a>
                    <?php elseif($v['progress'] == 2):?>
                        <a href="javascript:;" class="btn btn-danger btn-xs refuse radius-none">拒绝申请</a>
                        <a href="javascript:;" class="btn btn-success btn-xs pass radius-none">申请通过</a>
                    <?php endif;?>

                </td>
            </tr>
        <?php endforeach;?>
    <?php else:?>
        <tr>
            <td colspan="13" style="text-align: center; font-size: 20px; line-height: 50px">

                没有找到符合条件的数据!

            </td>
        </tr>
    <?php endif;?>
</table>
<div role="group" data-total="<?php echo $total?>" data-page="<?php echo $page?>" data-nums="<?php echo $nums?>" data-src="<?php echo U('Admin/AfterSales/Index/lists');?>"  class="btn-group" id="_pages"></div>
<script>
    $(function(){

        $('[data-toggle="tooltip"]').tooltip();

        var options = {

            'progress': '<?php echo $progress?>'

        }

        Admin.pages(options);

        $('.images','#after-sales-list').unbind('click');
        $('.images','#after-sales-list').click(function(){

            var pic = $(this).data('pic');
            //var title = $(this).data('title');

            var options = {

                'title' : '',
                'id'    : 1,
                'start' : 0,
                'data'  : pic,

            }
            layer.photos({
                photos: options
            });
        });
        //开始处理
        $('.start').unbind('click');
        $('.start').click(function(){

            var _this = $(this);

            var id = _this.parent().data('id');
            var mobile = _this.parent().data('mobile');
            var number = _this.parent().data('number');

            layer.msg('确定开始处理吗？', {
                time: 0 //不自动关闭
                ,btn: ['确定', '关闭']
                ,yes: function(index){
                    layer.close(index);

                    $.ajax({
                        url: '<?php echo U("Admin/AfterSales/Index/start")?>',
                        type: 'post',
                        data: {'id':id,'mobile':mobile,'number':number},
                    })
                    .done(function(result){

                        var data = {}
                        var url = '';
                        if(result.code == 200){

                            var data = options;
                            data.page = "<?php echo $page?>";

                            url = '<?php echo U("Admin/AfterSales/Index/lists")?>';

                        }

                        showMessage(result.msg,result.code,url,data,2000);

                    })

                }
            });



        });
        //拒绝售后
        $('a.refuse').unbind('click');
        $('a.refuse').click(function(){

            var _this = $(this);

            var id = _this.parent().data('id');
            var mobile = _this.parent().data('mobile');
            var number = _this.parent().data('number');

            layer.prompt({title: '请输入拒绝原因', formType: 2}, function(reason){

                $.ajax({

                    url: '<?php echo U("Admin/AfterSales/Index/refuse")?>',
                    type: 'post',
                    data: {
                        'id'        :id,
                        'mobile'    :mobile,
                        'number'    :number,
                        'reason'    :reason
                    },
                })
                .done(function(result){

                    var data = {}
                    var url = '';
                    if(result.code == 200){

                        var data = options;
                        data.page = "<?php echo $page?>";

                        url = '<?php echo U("Admin/AfterSales/Index/lists")?>';

                    }

                    showMessage(result.msg,result.code,url,data,2000);

                })
            });

        })
        //申请通过
        $('a.pass').unbind('click');
        $('a.pass').click(function(){

            var _this = $(this);

            var id = _this.parent().data('id');
            var mobile = _this.parent().data('mobile');
            var number = _this.parent().data('number');

            layer.prompt({title: '备注', formType: 2}, function(reason){

                $.ajax({

                    url: '<?php echo U("Admin/AfterSales/Index/pass")?>',
                    type: 'post',
                    data: {
                        'id'        :id,
                        'mobile'    :mobile,
                        'number'    :number,
                        'reason'    :reason
                    },
                })
                .done(function(result){

                    var data = {}
                    var url = '';
                    if(result.code == 200){

                        var data = options;
                        data.page = "<?php echo $page?>";

                        url = '<?php echo U("Admin/AfterSales/Index/lists")?>';

                    }

                    showMessage(result.msg,result.code,url,data,2000);

                })
            });

        })
        //查看订单信息
        $('a.order-info').unbind('click');
        $('a.order-info').click(function(){

            var id = $(this).data('order_id');

            layer.load();

            $.post("<?php echo U('Admin/Order/Index/detail');?>",{"id":id},function(result){

                layer.closeAll();

                layer.open({
                    type: 1,
                    title: '订单信息',
                    area: ['100%', '100%'],
                    content: result,
                });

            });

        });
    });
</script>